
#ifndef ECARX_NET_RW_LOCK_H
#define ECARX_NET_RW_LOCK_H
#include <pthread.h>
namespace ecarx::transfer::lock {

class RWLock {
  pthread_rwlock_t _lock;

public:
  RWLock();
  int read();
  int write();
  int unlock();
};

class AutoRead {
  RWLock *_lock;

public:
  explicit AutoRead(RWLock *);
  AutoRead(AutoRead &) = delete;
  ~AutoRead();
};

class AutoWrite {
  RWLock *_lock;

public:
  AutoWrite(RWLock *);
  ~AutoWrite();
};

} // namespace swc::lock

#endif
